package com.kingyun.gpsinspection.purificationservice.services.activitiservice.base;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.activiti.ApprovalHistoryMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.activiti.ApprovalHistory;
import com.kingyun.gpsinspection.purificationservice.facade.service.activiti.base.ApprovalHistoryService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by jiangjx on 2017/11/17.
 */
public class ApprovalHistoryServiceImpl implements ApprovalHistoryService {

    @Autowired
    private ApprovalHistoryMapper approvalHistoryMapper;

    /**
     * 根据业务主键ID查询审批历史
     *
     * @param businessKey 业务主键id
     */
    @Override
    public JSONObject queryListInfo(String businessKey) throws Exception {
        JSONObject jsonObject = new JSONObject();
        List<ApprovalHistory> trainList = new ArrayList<>();
        if (!StringUtils.isEmpty(businessKey)) {
            trainList = approvalHistoryMapper.queryList(businessKey);
        }
        jsonObject.put("rows", JSON.toJSON(trainList));
        return jsonObject;
    }
}
